package com.lyf.scm.plan.domain.repository;

import com.lyf.scm.plan.api.dto.SalePlanDirectlyDifferinInfoDTO;
import com.lyf.scm.plan.api.dto.SalesPlanDirectlyAccuracyDTO;
import com.lyf.scm.plan.api.dto.SalesPlanDirectlyAccuracyInfoDTO;
import com.lyf.scm.plan.insfrastructure.db.dataobject.SalesPlanSelectDO;
import com.lyf.scm.plan.insfrastructure.db.dataobject.bigdata.DirectlyAccuracyInDO;
import com.lyf.scm.plan.insfrastructure.db.dataobject.bigdata.DirectlyAccuracyUpDO;
import com.lyf.scm.plan.insfrastructure.db.mapper.SalesPlanDirectlyAccuracyMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 直营预测计划_销售计划准确率
 *
 * @author wangchlei
 * @date 2020/08/13
 */
@Service
public class SalesPlanDirectlyAccuracyRepository {
    @Resource
    private SalesPlanDirectlyAccuracyMapper salesPlanDirectlyAccuracyMapper;

    /**
     * 非分页查询
     *
     * @param salesPlanSelectDO
     * @return {@link List<SalesPlanDirectlyAccuracyInfoDTO>}
     **/
    public List<SalesPlanDirectlyAccuracyInfoDTO> listByCycles(SalesPlanSelectDO salesPlanSelectDO) {
        return salesPlanDirectlyAccuracyMapper.listByCycles(salesPlanSelectDO);
    }

    public List<SalesPlanDirectlyAccuracyInfoDTO> eChartsData(SalesPlanSelectDO salesPlanSelectDO) {
        return salesPlanDirectlyAccuracyMapper.listEChartsDataByCycles(salesPlanSelectDO);
    }

    /**
     * 导出所有查询数据
     *
     * @param salesPlanSelectDO
     * @return {@link List<SalesPlanDirectlyAccuracyInfoDTO>}
     **/
    public List<SalesPlanDirectlyAccuracyInfoDTO> searchedDataExport(SalesPlanSelectDO salesPlanSelectDO) {
        return salesPlanDirectlyAccuracyMapper.listByCycles(salesPlanSelectDO);
    }

    /**
     * 大数据批量新增
     *
     * @param directlyAccuracyInDOs
     * @return void
     **/
    public void batchInsert(List<DirectlyAccuracyInDO> directlyAccuracyInDOs) {
        salesPlanDirectlyAccuracyMapper.batchInsert(directlyAccuracyInDOs);
    }

    public void batchDeleteByStartDate(String storeCode, Date weekStartDate) {
        salesPlanDirectlyAccuracyMapper.batchDeleteByStartDate(storeCode, weekStartDate);
    }

    public List<DirectlyAccuracyUpDO> listUpByStoreAndDate(String code, Date startDate, Date endDate) {
        return salesPlanDirectlyAccuracyMapper.listUpByStoreAndDate(code, startDate, endDate);
    }

    public void rmByIds(List<Long> ids) {
        salesPlanDirectlyAccuracyMapper.rmByIds(ids);
    }

    public void upByIds(List<DirectlyAccuracyUpDO> list) {
        salesPlanDirectlyAccuracyMapper.upByIds(list);
    }

    public void delete(String opSign){
        salesPlanDirectlyAccuracyMapper.delete(opSign);
    }

    public void deleteByOpSign(String opSign) {
        salesPlanDirectlyAccuracyMapper.deleteByOpSign(opSign);
    }
}
